#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#define int long long
using namespace std;

const int N = 1e5 + 5;
int d[N],v[N],a[N],p[N];
bool vis[N];

signed main()
{
    //freopen("detect.in","r",stdin);
    //freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    while (t--)
    {
        int n,m,L,V,cnt = 0;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++)
            cin >> d[i] >> v[i] >> a[i];
        for (int i = 1; i <= m; i++)
            cin >> p[i];
        sort(p + 1,p + m + 1);
        memset(vis,false,sizeof(vis));
        vector<int> check[N];
        for (int i = 1; i <= n; i++)
        {
            while (d[i] >= 0 && d[i] <= L && v[i] != 0)
            {
                if (v[i] > V)
                {
                    int x = lower_bound(p + 1,p + m + 1,d[i]) - p;
                    if (p[x] == d[i]) check[x].push_back(i);
                }
                d[i] += v[i];
                v[i] += a[i];
            }
        }
        for (int i = 1; i <= m; i++)
        {
            bool flag = true;
            for (int val: check[i])
                if (!vis[val])
                {
                    flag = false;
                    break;
                }
            for (int val: check[i])
                vis[val] = true;
            if (flag) cnt++;
        }
        cout << cnt << " " << cnt << endl;
    }
    return 0;
}
